import java.util.LinkedList;
import java.util.Queue;

class Solution1700 {
    public static void main(String[] args) {
        int[] a = {1,1,1,0,0,1};
        int[] b = {1,0,0,0,1,1};
        System.out.println(countStudents(a , b));
    }
    public static int countStudents(int[] students, int[] sandwiches) {
          int len = students.length ;
          Queue<Integer> queue = new LinkedList<>() ;
          int i = 0 ;
        for(int tmp : students){
            queue.add(tmp) ;
        }
          while(!queue.isEmpty()){
             int size = queue.size() ;
             int tmp = size ;
             while(tmp > 0){
              if(queue.peek() == sandwiches[i]){
               queue.poll() ;
               i++ ;
              }else{
                queue.add(queue.poll());
              }
               tmp -- ; 
             }
             if(size == queue.size()){
                return size ;
             }
          }

         return 0 ; 
    }
}